package com.github.cyf.ppt;

import org.apache.poi.xslf.usermodel.*;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;

import java.awt.*;

/**
 * @author chenyifan
 * @create 2025-06-27 17:10
 */
public class PPTTest2 {
    public static void main(String[] args) {
        XMLSlideShow ppt = new XMLSlideShow();
        XSLFSlide slide = ppt.createSlide();
        XSLFTextBox shape = slide.createTextBox();

        // 创建段落和文本运行
        XSLFTextParagraph paragraph = shape.addNewTextParagraph();
        XSLFTextRun run = paragraph.addNewTextRun();
        run.setText("这是黑色文本，这是红色文本，这是蓝色文本");
        run.setFontColor(Color.blue);

        XSLFTextRun run2 = paragraph.addNewTextRun();
        run.setText("黑色文本，这是红色文本，这是蓝色文本");
        run.setFontColor(Color.red);

        // 获取底层XML对象
        CTRegularTextRun xmlObject = (CTRegularTextRun) run.getXmlObject();

        System.out.println();
    }
}
